package BIJiaoQi;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/*
内部比较器
 */
public class TestPerson{
    public static void main(String[] args) {
        Person P1=new Person(16,"Ls",18,"ShanTou");
        Person P2=new Person(31,"ZS",17,"guangzhou");
        Person P3=new Person(16,"WW",76,"Shenzhen");
        Person P4=new Person(12,"ZL",26,"MaoMing");
        List<Person> person=new ArrayList<>();
        person.add(P1);
        person.add(P2);

        person.add(P3);
        person.add(P4);
       Collections.sort(person);
        System.out.println(person);
        System.out.println("-----------------");
        Student P5=new Student(16,"Ls",18);
        Student P6=new Student(31,"ZS",17);
        Student P7=new Student(16,"WW",76);
        Student P8=new Student(12,"ZL",26);
        List<Student> students=new ArrayList<>();
        students.add(P5);
        students.add(P6);
        students.add(P7);
        students.add(P8);
        //比较时如果使用外部比较器，需要重写一个
        Collections.sort(students,new MyComparatorWithId());
        System.out.println(students);
        System.out.println("你好啊");
    }
}
